/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package SISAC.DACEA.SERVLETS;

import SISAC.DACEA.BL.MatriculaBL;
import SISAC.DACEA.ENTITY.CicloAcademico;
import SISAC.DACEA.ENTITY.Cobro;
import SISAC.DACEA.ENTITY.Salon;
import com.google.gson.Gson;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.ResultSet;
import java.util.ArrayList;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author davis
 */
public class SCargarArea extends HttpServlet {

    /**
     * Processes requests for both HTTP
     * <code>GET</code> and
     * <code>POST</code> methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        try {
            /* TODO output your page here. You may use following sample code. */
            ResultSet res;
             double cuota;
            Cobro oCobro1;
            Cobro oCobro = new Cobro();
            oCobro.setCodigoCobro(2);
            oCobro1 = new MatriculaBL().obtenerCuotas(oCobro);
            
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet SCargarArea</title>");
            out.println("</head>");
            out.println("<body>");
            out.println("<h1>listado cuotas </h1>");
            cuota=oCobro1.getCuotaUno();
            out.println("<li>"+cuota+"</li>");
            out.println("</body>");
            out.println("</html>");
        } finally {
            out.close();
        }
    }

    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    /**
     * Handles the HTTP
     * <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);

//        Cobro oCobro1;
////        CicloAcademico oCicloAcademico;
//        Cobro oCobro = new Cobro();
////        
////        oCicloAcademico=new MatriculaBL().alistarCiclo();
////        
//        oCobro.setCodigoCobro(2);
////        System.out.println(oCicloAcademico.getNombreCiclo());
////        System.out.println(oCicloAcademico.getCodigoCobro());
//
//        oCobro1 = new MatriculaBL().obtenerCuotas(oCobro);
//        System.out.println(String.valueOf(oCobro1.getCuotaUno()));
//
//
//        //ArrayList<Salon> lstArea= new ArrayList<Salon>();
////        lstArea.add(oSalon);
////        lstArea.add(oSalon1);
////        lstArea.add(oSalon2);
//
//        String json1 = new Gson().toJson(oCobro1);
//        response.setContentType("application/json");
//        response.setCharacterEncoding("utf-8");
//        response.getWriter().write(json1);
    }

    /**
     * Handles the HTTP
     * <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);

    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }// </editor-fold>
}
